<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>小型Toast式图片预览示例</title>
    <style>
        /* 遮罩层样式 */
        #overlay-background {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
            z-index: 999;
        }

        /* 弹出层样式 */
        #overlay {
            display: none;
            position: relative;
            background-color: white;
            padding: 16px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            z-index: 1000;
            max-width: 300px; /* 设置最大宽度 */
            margin:0 auto;
            text-align: center;
        }

        #previewImage {
            max-width: 100%;
            height: auto;
            border-radius: 8px;
        }

        #closeOverlay {
            position: absolute;
            top: 5px;
            right: 5px;
            font-size: 20px;
            color: #333;
            cursor: pointer;
            transition: color 0.3s ease-in-out;
        }

        #closeOverlay:hover {
            color: #ffcc00;
        }

        /* 表格样式 */
        table {
            width: 100%;
            margin: auto;
            border-collapse: collapse;
        }

        td {
            padding: 10px;
            text-align: center;
            vertical-align: middle;
        }

        .thumbnail {
            cursor: pointer;
            transition: opacity 0.3s ease-in-out;
        }

        .thumbnail:hover {
            opacity: 0.7;
        }
    </style>
</head>
<body>
<table>
    <tr>
        <td>111</td>
        <td><img src="https://www.baidu.com/img/flexible/logo/pc/result.png" class="thumbnail" alt="Baidu Logo"/></td>
    </tr>
</table>

<!-- 全屏遮罩层 -->
<div id="overlay-background"></div>

<!-- Toast式弹出层用于显示大图 -->
<div id="overlay">
    <span id="closeOverlay">&times;</span>
    <img id="previewImage" src="" alt="Preview Image">
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
    // 点击缩略图显示大图
    $('.thumbnail').click(function(event) {
        event.preventDefault();
        var fullSrc = $(this).attr('src');
        $('#previewImage').attr('src', fullSrc);

        // 显示遮罩层和弹出层
        $('#overlay-background, #overlay')
            .css('display', 'flex')
            .hide()
            .fadeIn(300);
    });

    // 点击关闭按钮隐藏大图和遮罩层
    $('#closeOverlay').click(function() {
        closeOverlay();
    });

    // 点击遮罩层外部也关闭大图和遮罩层
    $('#overlay-background').click(function(event) {
        closeOverlay();
    });

    function closeOverlay() {
        $('#overlay-background, #overlay').fadeOut(300, function() {
            $(this).css('display', 'none');
        });
    }
});
</script>
</body>
</html>